package com.netrust.cmsx.entity.module.cms;

import static javax.persistence.GenerationType.IDENTITY;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name="t_article_comment")
public class ArticleComment {
	private Integer id;
	
	private Integer aid;//关联文章外键
	
	@JsonIgnore
	private Article article;
	@JsonIgnore
	private Integer pid;//自关联评论id
	
	private List<ArticleComment> articleCommentChildren=new ArrayList<ArticleComment>();//自关联
	
	private String title;
	private String content;
	private String man;// 评论人
	private Integer status;
	private String auditMethod;//
	private Timestamp time;// 评论时间
	
	
	public ArticleComment() {
		super();
	}

	public ArticleComment(Integer id, Integer pid, List<ArticleComment> articleCommentChildren,
			String title, String content, String man, Integer status, String auditMethod, Timestamp time) {
		super();
		this.id = id;
		this.pid = pid;
		this.articleCommentChildren = articleCommentChildren;
		this.title = title;
		this.content = content;
		this.man = man;
		this.status = status;
		this.auditMethod = auditMethod;
		this.time = time;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ac_id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name="ac_aid",insertable=false,updatable=false)
	public Integer getAid() {
		return aid;
	}

	public void setAid(Integer aid) {
		this.aid = aid;
	}
	
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name="ac_aid")
	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	@Column(name="ac_p_id")
	public Integer getPid() {
		return pid;
	}
	public void setPid(Integer pid) {
		this.pid = pid;
	}

	@Transient
	public List<ArticleComment> getArticleCommentChildren() {
		return articleCommentChildren;
	}
	
	public void setArticleCommentChildren(List<ArticleComment> articleCommentChildren) {
		this.articleCommentChildren = articleCommentChildren;
	}
	
	@Column(name="ac_title")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(name="ac_content")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	@Column(name="ac_man")
	public String getMan() {
		return man;
	}

	public void setMan(String man) {
		this.man = man;
	}
	
	@Column(name="ac_status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	@Column(name="ac_audit_method")
	public String getAuditMethod() {
		return auditMethod;
	}

	public void setAuditMethod(String auditMethod) {
		this.auditMethod = auditMethod;
	}
	
	@Column(name="ac_time")
	public Timestamp getTime() {
		return time;
	}

	public void setTime(Timestamp time) {
		this.time = time;
	}

	@Override
	public String toString() {
		return "ArticleComment [id=" + id + ", aid=" + aid + ", pid=" + pid + ", articleCommentChildren="
				+ articleCommentChildren + ", title=" + title + ", content=" + content
				+ ", man=" + man + ", status=" + status + ", auditMethod=" + auditMethod + ", time=" + time + "]";
	}
	
}
